﻿namespace WriterStars.Models.ViewModels
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    public class BlogViewModel
    {
        private int booksPerPage;

        public BlogViewModel(int currentPage, int booksCount, int booksPerPage = 3)
        {
            this.BlogBooks = new List<AuthorViewModel>();
            this.SuggestedBooks = new List<AuthorViewModel>();
            this.booksPerPage = booksPerPage;
            this.CurrentPage = currentPage;
            this.BooksCount = booksCount;
        }

        public int PagesCount
        {
            get
            {
                int threeBookPages = this.BooksCount / this.booksPerPage;
                return this.BooksCount % this.booksPerPage == 0 ? threeBookPages : threeBookPages + 1;
            }
        }

        public int CurrentPage { get; set; }

        public int BooksCount { get; set; }

        public IEnumerable<AuthorViewModel> BlogBooks { get; set; }

        public IEnumerable<AuthorViewModel> SuggestedBooks { get; set; }
    }
}